#!/usr/bin/env python

import os, sys, glob

topdir = os.getcwd()

# Put the plugin directory in the environment so that setuptools won't barf
# when placing the eggs into a non-syntem directory
os.environ['PYTHONPATH'] = topdir


def process(path):
    if os.path.isfile(os.path.join(path, "setup.py")):
        print("processing %s" % path)
        os.chdir(path)
        os.system("python setup.py bdist_egg -d %s" % topdir)
    else:
        print("skipping non-plugin dir %s" % path)

dirs = os.listdir(topdir)
for d in dirs:
    os.chdir(topdir)
    if os.path.isdir(d):
        print("\n-----")
        process(d)
